<template>
  <div>
    <city-header></city-header>
    <city-search :list="citys"></city-search>
    <city-list :hotCities="hotCities" :citys="citys" :char="char"></city-list>
    <city-char :citys="citys" @charClick="handleCityCharClick"></city-char>
  </div>
</template>

<script>
import CityHeader from './components/Header'
import CitySearch from './components/Search'
import CityList from './components/List'
import CityChar from './components/Char'
import axios from 'axios'
export default {
  name: 'City',
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityChar
  },
  data () {
    return {
      citys: {},
      hotCities: [],
      char: ''
    }
  },
  methods: {
    getCityInfo () {
      axios.get('/api/city.json').then(this.getCityInfoSucc)
    },
    getCityInfoSucc (res) {
      let result = res.data
      if (result.ret && result.data) {
        let data = result.data
        this.citys = data.cities
        this.hotCities = data.hotCities
      }
    },
    handleCityCharClick (char) {
      this.char = char
    }
  },
  mounted () {
    this.getCityInfo()
  }
}
</script>

<style lang="stylus" scoped>

</style>
